<?

require_once ("application.fieldset.inc");

global $_GLOBAL_DBH;
global $_OBJECT_IFACE_PANEL;

if (!isset ($_REQUEST["date_begin_dy"])) _app_timestamp_date ("date_begin", $_REQUEST["timestamp"]);
if (!isset ($_REQUEST["date_end_dy"])) _app_timestamp_date ("date_end", $_REQUEST["timestamp"]);

$fieldset_timesheets = new Fieldset (array (
	db_conn=>$_GLOBAL_DBH,
	relation=>"schedule",
	fieldset=>array (
		array (name=>"id",label=>"ID",type=>"numeric",
				value=>$_REQUEST["timesheet_id"],
				input=>"hidden",primary_key=>true),
		array (name=>"user_id",label=>"User ID",type=>"any",
				input=>"hidden",value=>$_APP_SESSION_USER->id),
		array (name=>"date_begin",label=>"Date Begin",type=>"any",
				input=>"date_time",value=>_app_date_time("date_begin")),
		array (name=>"date_end",label=>"Date End",type=>"any",
				input=>"date_time",value=>_app_date_time("date_end")),
	)
));

$fieldset_timesheets->parse ();

$return = "/?fs_tab=schedule&timesheet_id=&fs_action=view";

$fs_options = array (
	addnew=>array (label=>"Add New"),
	create=>array (label=>"Create"),
	modify=>array (label=>"Modify"),
	remove=>array (label=>"Remove"),
	update=>array (label=>"Update"),
	cancel=>array (label=>"Cancel"),
	delete=>array (label=>"Delete",
			redirect=>dirname ($_SERVER["PHP_SELF"]) . $return),
	canret=>array (label=>"Cancel",
			redirect=>dirname ($_SERVER["PHP_SELF"]) . $return),
	close=>array (label=>"Close",
			redirect=>dirname ($_SERVER["PHP_SELF"]) . $return),
);

$image_options = array (size=>$_REQUEST["_img_size"]);

list ($fs_input, $fs_action, $store, $valid, $success) =

	_app_process_fieldset (array (
		fieldset=>$fieldset_timesheets,
		fs_options=>$fs_options,
		fs_primary_key=>"timesheet_id",
		fs_action=>($_REQUEST["fs_action"] ?
				$_REQUEST["fs_action"] :
				"view"),
));

$_OBJECT_FIELDSET_CONTROL =_app_create_fieldset_object (array (
	fieldset_id=>"fs_timesheets",
	db_conn=>$_GLOBAL_DBH,
	fieldset=>$fieldset_timesheets,
	fs_action=>$fs_action,
	fs_input=>$fs_input,
	fs_link=>"?fs_action=view&fs_tab=schedule&fs_tab_option=fs_schedule&timesheet_id={$_REQUEST["timesheet_id"]}",
	fs_options=>$fs_options,
));

$_OBJECT_IFACE_TABBING_PANEL->insert_container ($_OBJECT_FIELDSET_CONTROL);

?>
